Wait a second.
When you have an ASP.NET button you have to be careful setting the onclick="someFunction".
For example if you create an ASP.NET Button and set it's onclick property:
- <asp:Button ID="MyButton" runat="server" onclick="someFunction()" />
The button will attempt to call a Server Side function named "someFunction" when it is clicked. This will not execute a JavaScript function named "someFunction".
If you want to execute a JavaScript function during an onclick event you have to use the OnClientClick Property to do so:
- <asp:Button ID="MyButton" runat="server" OnClientClick="someFunction()" />
Normally I don't use the OnClientClick property. I usually set the JavaScript events for controls like buttons server side in either the Page Load or Page PreRender event:
-
MyButton.Attributes.Add("onclick","someFunction();")
Please note that if you do not "return false" during a JavaScript onclick event, the button will submit the page to the server. When your page submits to the server, any client side (JavaScript) stuff done will be "undone" when the page is recreated in the browser....
Therefore, it is "usually" a good idea to add "return false;" in your buttons.
For example:
(server code)
-
MyButton.Attributes.Add("onclick","someFunction(); return false;")
(asp declaration code)
- <asp:Button ID="MyButton" runat="server" OnClientClick="someFunction();return false;" />
I honestly don't know how you got your ASP button to call a JavaScript function using the onclick property....